// app.js
import {
  Post,
  Get
} from "./utils/request.js"
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录 哈哈哈哈
    if(!wx.getStorageSync('token')){
         wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        console.log(res, '发送 res.code 到后台换取')
        Get("/wx/user/wx38e17bf12e912a3b/login", {
            appid: 'wx38e17bf12e912a3b',
            code: res.code,
          })
          .then(res => {
            if (res.data!=="") {
              wx.setStorageSync('token', res.data)
            }
            console.log(res, "shuju")
          })
      }
    })
    }
  },
  globalData: {
    userInfo: null
  }
})
